<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html>
<head>

<c:import url="/common/base-hplus.jsp" />

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-6">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>密码修改</h5>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="signupForm">
                       		<input type="hidden" name="userId" id="userId" value="${userinfo.userId}" />
                            <div class="form-group">
                                <label class="col-sm-3 control-label">原密码：</label>
                                <div class="col-sm-8">
                                    <input id="oldPasswd" name="oldPasswd" class="form-control" type="password" aria-required="true" aria-invalid="true" class="error">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">新密码：</label>
                                <div class="col-sm-8">
                                    <input id="newUserPassword" name="newUserPassword" class="form-control" type="password">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">确认密码：</label>
                                <div class="col-sm-8">
                                    <input id="newUserPasswordAgain" name="newUserPasswordAgain" class="form-control" type="password">
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i><font color="red">${message }</font></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary btn-smb" type="button">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
    
    <script>
	    
		$.validator.setDefaults({
			highlight : function(a) {
				$(a).closest(".form-group").removeClass("has-success").addClass("has-error")
			},
			success : function(a) {
				a.closest(".form-group").removeClass("has-error").addClass("has-success")
			},
			errorElement : "span",
			errorPlacement : function(a, b) {
				if (b.is(":radio") || b.is(":checkbox")) {
					a.appendTo(b.parent().parent().parent())
				} else {
					a.appendTo(b.parent())
				}
			},
			errorClass : "help-block m-b-none",
			validClass : "help-block m-b-none"
		});
		$().ready(function() {
			var a = "<i class='fa fa-times-circle'></i> ";
			$("#signupForm").validate({
				rules : {
					oldPasswd : {
						required : true
					},
					newUserPassword : {
						required : true,
						minlength : 6,
						maxlength : 16
					},
					newUserPasswordAgain : {
						required : true,
						minlength : 6,
						maxlength : 16,
						equalTo : "#newUserPassword"
					}
				},
				messages : {
					oldPasswd : {
						required : a + "请输入您的原密码"
					},
					newUserPassword : {
						required : a + "请输入您的密码",
						minlength : a + "密码必须6-16个字符以上",
						maxlength : a + "密码必须6-16个字符以上"
					},
					newUserPasswordAgain : {
						required : a + "请再次输入密码",
						minlength : a + "密码必须6-16个字符以上",
						maxlength : a + "密码必须6-16个字符以上",
						equalTo : a + "两次输入的密码不一致"
					},
				}
			});
			
			
			
			$(".btn-smb").click(function() {
				var flag = $("#signupForm").valid();
				if(!flag){
					return ;
				}
				
				
				var title = "您确定要修改密码吗？";
				var src = "/system/user/tMgtUser/updatePassword.do";
				$.SwalAjaxRequestHelper.AjaxSwalRequest(title, src, $('#signupForm').serialize(), function(data) {
					 swal({
				     	title: "系统提示",
				        text: data.message,
				        type: "info",
				        confirmButtonColor: "#DD6B55",
				        confirmButtonText: "确定",
				        closeOnConfirm: true
					 }, function () {
						if(data.flag != "success"){
	                		swal("操作失败!", data.message, "error");
	                	}else{
	                		swal("操作成功!", data.message, "success");
	                		$("#oldPasswd").val("");
	    					$("#newUserPassword").val("");
	    					$("#newUserPasswordAgain").val("");
	               		}
					});
				});
				
				
			})
					
					
			
		});
		
		
		/* function updatePass() {
			var url = '/system/user/tMgtUser/updatePassword.do';
			$.AjaxRequestHelper.AjaxJsonRequest(url, $("#resetPass").serialize(), function(data) {
				$.messager.alert("系统提示", data.message,"info", function(){
					$("#oldPasswd").val("");
					$("#newUserPassword").val("");
					$("#newUserPasswordAgain").val("");
					if(data.flag=="isChange"){
						location.href="/system/user/login/logout.do";
					}
				});
			});
		} */
		
		
</script>

</body>



</html>
